<%--
  Created by IntelliJ IDEA.
  User: User
  Date: 2020/6/1
  Time: 21:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>车票明细</title>
</head>
<jsp:useBean id="db" class='hello.DB'></jsp:useBean>
<body style="background:url(page/1.jpg)">
hello：<%out.print(session.getAttribute("user"));%>
<br><h1 align="center">请确定您的订单</h1>
<%@ page import="java.sql.*" %>
<%	String trainnum=request.getParameter("trainnum");
    session.setAttribute("trainnum",trainnum);
    String begin=(String)session.getAttribute("begin");
    String end=(String)session.getAttribute("end");
    String day=(String)session.getAttribute("day");
%>
<%
    db.init();
    String sql="declare @price float "+
            "exec getprice '"+trainnum+"','"+begin+"','"+end+"',@price out "+
            "select @price p,@price*1.6 p1";
    ResultSet rs=db.executeQuery(sql);
    String price="",price2="";
    if(rs.next()){
        price=rs.getString("p");//2等
        price2=rs.getString("p1");//1等
        session.setAttribute("price2",price2);
        session.setAttribute("price",price);
    }
    if(price.length()>5)price=price.substring(0,4);
    if(price2.length()>5){
        price2=price2.substring(0,4);
    }
%>
<table border="1">
    <tr><td>车次</td><td>出发</td><td>终点</td><td>一等座</td><td>二等座</td><td>无座</td></tr>
    <tr><td width="10%"><%out.print(trainnum); %></td>
        <td width="8%"><%out.print(begin); %></td>
        <td width="8%"><%out.print(end); %></td>
        <td width="8%"><%out.print(price2+"元"); %></td>
        <td width="8%"><%out.print(price+"元"); %></td>
        <td width="8%"><%out.print(price+"元"); %></td></tr>
</table>
<form action="success.jsp">
    乘客名：<input name="passenger" type ="text" /><br>
    身份证号：<input name="idnum" type ="text" /><br>
    <input  name="seattype"type="radio" value="一等座"/>一等座
    <input checked="true"  name="seattype"type="radio" value="二等座"/>二等座
    <input name="seattype"type="radio" value="无座"/>无座<br>
    <input type="submit" value='确认购买'/>
</form>
<%db.close(); %>
</body>
</html>
